/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.controller;


import io.renren.common.exception.RRException;
import io.renren.common.utils.R;
import io.renren.modules.nas.service.UploadFileService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;

/**
 * APP登录授权
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/app")
@Api("APP登录接口")
public class AppFileController {

    @Autowired
    private UploadFileService uploadFileService;



    @PostMapping("/uploadPayAuditFile")
    public R uploadPayAuditFile(MultipartFile[] files, final HttpServletRequest request) {


        ArrayList<Integer> uploadIds = null;
        try {
            uploadIds = uploadFileService.uploadFile(files, null);
        } catch (RRException e) {
            return R.error(e.getMsg());
        }
        return R.ok().put("uploadId", uploadIds.get(0));
    }
}
